<?php

namespace app\admin\controller;

/**
 * 图片上传控制器
 * Class Role
 * @package app\admin\controller
 */
class Upload extends Base
{
    //图片上传
    public function getOos()
    {
        $oos = config('oos');
        return admin_json(1, '获取成功',$oos);
    }
    /**
     * [getIndex  获取banner]
     * @param
     * @return json
     * @author [C。]
     */
    public function ceshioos()
    {
        $oos = array(
            'accessKeyId' => 'LTAIUZZ0EO0Xlz0c',
            'accessKeySecret' => 'ZPPOxFBERpKvaw4uO5oZVbdgnd5cRd ',
            'bucket' => 'fushance',
            'regin' => 'oss-cn-beijing',
            'image_url' => 'fushance.oss-cn-beijing.aliyuncs.com',
        );
        return admin_json(1, '获取成功',$oos);
    }
    //图片上传
    public function upload()
    {
        $file = request()->file('file');
        $info = $file->move('public' . DS . 'uploads' . DS . 'images');
        if ($info) {
            echo $info->getSaveName();
        } else {
            echo $file->getError();
        }
    }

    //会员头像上传
    public function uploadface()
    {
        $file = request()->file('file');
        $info = $file->move('uploads' . DS . 'face');
        if ($info && $info && $info->getPathname()) {
            $path = '/' . $info->getPathname();
            echo $path;
        } else {
            echo $file->getError();
        }
    }


    /**
     * [uploadOne  webUploader上传图片]
     * @author [C.]
     * @param string $folder 保存图片文件夹名
     */
    public function webUploaderImages($folder = 'images')
    {
        $folder = !empty(input('param.folder')) ? input('param.folder') : $folder;

        $file = request()->file('file');
        $info = $file->move('uploads' . DS . $folder);
        if ($info && $info->getPathname()) {
            $path = '/' . $info->getPathname();
            return admin_json(1, 'OK', ['path' => $path]);
        } else {
            return admin_json(-1, $file->getError());
        }
    }


}